import re
import pyperclip


class TextCleaner:
    """用于清理文本中仅含中文内容的括号部分"""

    def __init__(self):
        # 定义要匹配的中日韩括号类型
        self.pattern = r'（(.*?)）|【(.*?)】|｛(.*?)｝|《(.*?)》'

    def should_remove(self, content: str) -> bool:
        """判断括号内容是否应删除（不含英文字母则删除）"""
        return not re.search(r'[A-Za-z]', content)

    def clean_text(self, text: str) -> str:
        """清理单行文本"""
        def replacer(match):
            for i in range(1, 5):
                group = match.group(i)
                if group is not None:
                    return '' if self.should_remove(group) else match.group(0)
            return match.group(0)

        return re.sub(self.pattern, replacer, text)

    def process_input(self):
        """从命令行读取输入并输出结果"""
        print("请输入多行文本，以 'end' 结束：")
        lines = []
        while True:
            line = input()
            if line.strip() == 'end':
                break
            lines.append(line)

        cleaned_lines = [self.clean_text(line) for line in lines]
        result = '\n'.join(cleaned_lines)


        print("处理完成，结果已复制到剪贴板。")


if __name__ == "__main__":
    cleaner = TextCleaner()
    cleaner.process_input()
